package tools;

import java.io.Serializable;

public class Card implements Comparable<Card>, Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1066358012409795201L;
	private String suit;
	private String rank;
	private int value;
  
	public Card(String suit, String rank, int value)
	{
		this.suit=suit.toLowerCase();
		this.rank=rank.toUpperCase();
		this.value=value;
	}       
  
	public int compareTo(Card c)
	{
		return (this.value - c.value);
	}
  
	public boolean equals(Object o)
	{
		return ((Card)o).value == this.value; // contains to wywoluje
	}
  
	public int hashCode() 
	{
		return this.value;
	}
  
	public int getValue()
	{
		return value;
	}
  
	public String getRank()
	{
		return rank.toUpperCase();
	}

	public String getSuit()
	{
		return suit.toLowerCase();
	}

	public String getRankSuit()
	{
		return rank.toUpperCase() + suit.toLowerCase();
	}

	public boolean sameRank(Card c)
	{
		return (rank.compareTo(c.rank) == 0);
	}

	public boolean sameSuit(Card c)
	{
		return (suit.compareTo(c.suit) == 0);
	}
	
	public boolean sameCard(Card c)
	{
		return this.sameRank(c) && this.sameSuit(c);
	}
	
	public String toString()
	{
		return this.getRankSuit();
	}
}       
